Skip to content

fix: handle remaining PHPUnit TestResult events in parallel state#1683

Open
stsepelin wants to merge 3 commits into
pestphp:4.xfrom
stsepelin:fix/state-generator-runner-events
Open

fix: handle remaining PHPUnit TestResult events in parallel state#1683
stsepelin wants to merge 3 commits into
pestphp:4.xfrom
stsepelin:fix/state-generator-runner-events

Conversation

@stsepelin
Copy link
Copy Markdown
Contributor

@stsepelin stsepelin commented Apr 22, 2026

What:

  • Bug Fix

Description:

Follow-up to #1655. Extends Pest\Support\StateGenerator to process the PHPUnit\TestRunner\TestResult\TestResult methods it was still ignoring, so runner-level issues, skipped suites, and user-triggered errors show up in the parallel summary.

Handlers added:

  • errors()FAIL
  • testSuiteSkippedEvents()SKIPPED
  • testRunnerTriggeredDeprecationEvents()DEPRECATED
  • testRunnerTriggeredNoticeEvents()NOTICE
  • testRunnerTriggeredWarningEvents()WARN

Runner-level and suite-level events have no attached test, so they go through a small addStandaloneEvent helper that synthesises a TestMethod — same approach already used for the fabricated passed-test entries.

Two further commits tidy the surrounding code without changing behaviour:

  • Shared loop shapes fold into private helpers: addIssueEvents for per-triggering-test events (deprecations, notices, warnings, the new errors()), addThrowableEvents for test()/throwable() pairs (failed + marked-incomplete), and addStandaloneEvents for the three runner-level event groups. The existing addTriggeredPhpunitEvents now also consumes testConsideredRiskyEvents, since it shares the same nested-array shape.
  • Synthesised TestMethod ids are derived from the foreach index instead of a stateful counter — each call site already supplies a unique className, so className::event#<index> stays distinct.

Unit coverage for each new handler lives in tests/Unit/Support/StateGenerator.php.

Related:

Closes #1462 (the "missing implementations in StateGenerator.php" part)

stsepelin added 3 commits May 4, 2026 10:50
Covers testSuiteSkippedEvents, errors, and the three
testRunnerTriggered{Deprecation,Notice,Warning} event collections so
that invalid datasets, runner-level issues, and skipped suites are
reflected in the parallel summary.
Extracts the shared shapes scattered across fromPhpUnitTestResult into
private helpers:

- addIssueEvents: per-triggering-test loops (deprecations, notices,
  warnings, errors).
- addThrowableEvents: test()/throwable() loops (testFailedEvents and
  testMarkedIncompleteEvents).
- addStandaloneEvents: the three runner-level event loops.
- addTriggeredPhpunitEvents: now also accepts testConsideredRiskyEvents
  since it shares the same nested-array shape and test()/message()
  surface.

No behavior change.
Drops the per-call counter in favour of the foreach index. Each caller
already passes a unique className per event group, so className plus
index is enough to keep every synthesised TestMethod id distinct
without tracking mutable state on the generator.
@stsepelin stsepelin force-pushed the fix/state-generator-runner-events branch from 788c461 to 6591c7c Compare May 4, 2026 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Pest 4.0.2: missing implementations in StateGenerator.php

1 participant